package org.xxforest.game.core.scenes.scene2d.ui;

import org.xxforest.game.core.scenes.scene2d.XXNode;
import org.xxforest.game.core.utils.XXPoint;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;

public class XXShape extends XXNode {

	private ShapeRenderer renderer ;
	private ShapeType shapeType ;
	
	public XXShape(ShapeType shapeType , float width , float height){
		setWidth(width);
		setHeight(height) ;
		this.setAnchorPoint(XXPoint.create(width / 2, height /2));
		this.renderer = new ShapeRenderer();
		this.shapeType = shapeType ;
	}
	
	public static XXShape create(ShapeType shapeType , float width , float height){
		return new XXShape(shapeType,width,height) ;
	}
	
	@Override
	public void draw(SpriteBatch batch , float delta) {
		
		float x = getDrawX();
		float y = getDrawY();
		float scaleX = getDrawScaleX();
		float scaleY = getDrawScaleY();
		float drawWith = getDrawWidth() ;
		float drawHeight = getDrawHeight() ;
		float originX = getDrawAnchorPointX();
		float originY = getDrawAnchorPointY() ;
		float rotation = getDrawRotation();

		batch.end();  
		renderer.setProjectionMatrix(batch.getProjectionMatrix());
		renderer.setTransformMatrix(batch.getTransformMatrix());
		renderer.begin(ShapeType.FilledRectangle);
		renderer.rotate(0,0,0, rotation);
		renderer.filledRect(0, 0, drawWith, drawHeight);
		renderer.end();
		batch.begin();
		
	}

	@Override
	public void onCreate() {
		
	}

	
}
